<template>
  <div class="container">
    <HeadCartBrand title="支付成功" showSearchBar="true" />

    <div class="yh-layout-box pay-box">
      <div class="payStatus bg-white">
        <div class="icon">
          <img src="@/assets/images/meal/status-success.png" alt="" v-if="status == 200">
          <img src="@/assets/images/meal/status-error.png" alt="" v-if="status != 200">
        </div>
        <p class="mt-20 pay-text yh-text-color" v-if="status == 200">
          您的订单已支付成功，请尽快联系卖家发货！
        </p>
        <div class="mt-20 error-text yh-text-color" v-if="status != 200">
          <span>支付失败！</span>
          查看支付常见问题
        </div>
      </div>
      <div class="pay-order-info" :class="{' pay-order-error':status != 200}">
        <div class="info" v-if="status == 200">
          <!-- <p><span class="name">交易号</span>：<span class="value">{{ info.orderNo }}</span></p> -->
          <p><span class="name">支付方式</span>：<span class="value">{{ info.payType == 1 ? '微信' : '支付宝支付' }}</span></p>
          <p><span class="name">支付时间</span>：<span class="value">{{ info.payTime }}</span></p>
          <p><span class="name">实付款</span>：<strong class="value">￥{{ info.payAmount }}</strong></p>
        </div>
        <div class="btn" v-if="status == 200">
          <router-link :to="{ path: '/' }" class="btn-view">继续采购</router-link>
          <router-link :to="{name: orderType == 2?'XorderDetail':'MemberOrderDetail', query:{ orderNo: info.orderNo }}" href="javascript:;">查看订单</router-link>
        </div>

        <div class="info"  v-if="status != 200">
          <p><span class="name">支付方式</span>：<span class="value">{{ info.payType == 1 ? '微信' : '支付宝支付' }}</span></p>
          <p><span class="name">实付款</span>：<strong class="value">￥{{ info.payAmount }}</strong></p>
        </div>
        <div class="btn" v-if="status != 200">
          <router-link :to="{name:'MealCashierOrder', query:{ productOrderNo: info.orderNo }}" href="javascript:;">重新支付</router-link>
          <router-link :to="{ path: '/' }" class="btn-view">继续采购</router-link>
          <router-link :to="{name:orderType == 2?'XorderDetail':'MemberOrderDetail', query:{ orderNo: info.orderNo }}" href="javascript:;">查看订单</router-link>
        </div>
      </div>
    </div>
    <LikeItem />
    <Footbar />
  </div>
</template>
<script>
import HeadCartBrand from '@/components/Layouts/HeadCartBrand.vue'
import LikeItem from '@/components/Business/LikeItem'
import Footbar from '@/components/Layouts/Footbar.vue'
import { getOrderDetail } from '@/api/order'
import { getXOrderDetail } from '@/api/xorder'

export default {
  name: 'MealPayStatusOrder',
  components: {
    HeadCartBrand,
    LikeItem,
    Footbar,
  },
  data() {
    return {
      status: 200, //成功
      info: {},
      orderType: this.getUrlParams('orderType')
    }
  },
  created() {
    if(this.orderType == 2){
      this.getXOrderDetail()
    }else{
      this.getOrderDetail()
    }

  },
  methods: {
    //获取订单详情
    getOrderDetail() {
      const params = {
        orderNo: this.getUrlParams('out_trade_no')
      }
      getOrderDetail(params).then(res => {
        if(res.code == 200){
          this.info = res.data
        }
      })
    },
    // 获取协议订单详情
    getXOrderDetail() {
      const params = {
        orderNo: this.getUrlParams('out_trade_no')
      }
      getXOrderDetail(params).then(res => {
        if(res.code == 200){
          this.info = res.data
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.pay-box{
  margin: 30px auto 50px;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 40px 0;
  overflow: hidden;
  background: #fff;
}
.payStatus{
  float: left;
  text-align: center;
  width: 430px;
  padding: 0 40px;
  border-right: 1px solid #eee;
}

.pay-order-info{
  float: left;
  width: 539px;
  font-size: 14px;
  color: #666;
  padding: 0 60px 0 90px;
  p{
    line-height: 24px;
  }
  .name{
    float: left;
    width: 60px;
    height: 24px;
    line-height: 24px;
    overflow: hidden;
    text-align: justify;
    &:after{
      display: inline-block;
      width: 100%;
      content: '';
    }
  }
  .value{
    width: auto;
    float: none;
    margin-left: 26px;
  }
  strong{
    font-size: 20px;
    font-weight: 400;
    color: #D0021B;
  }
  .info{
    float: left;
  }
  .btn{
    margin-top: 10px;
    float: right;
    a{
      display: block;
      width: 160px;
      height: 44px;
      line-height: 44px;
      text-align: center;
      margin-top: 20px;
      color: #fff;
      border-radius: 10px;
      background: #255B8B;
      text-decoration: none;
    }
    .btn-view{
      color: #255B8B;
      background: #fff;
      border: 1px solid #255B8B;
    }
  }
}

.pay-order-error{
  .info{
    margin-top: 40px;
  }
  .btn{
    margin-top: 0;
  }
  a:first-child{
    margin-top: 0;
  }
}

.error-text{
  span{
    display: block;
    font-size: 18px;
    margin-bottom: 10px;
  }
}

.pay-text{
  font-size: 18px;
  font-weight: 500;
  margin-top: 27px;
  margin-bottom: 6px;
}
.pay-main{
  overflow: hidden;
  text-align: left;
  padding: 52px 60px;
  width: 680px;
  margin: 0 auto;
  margin-top: 40px;
  background:rgba(247,247,247,1);
  .main-msg{
    color: #666;
  }
  .main-price{
    margin-top: 60px;
    color: #666666;
  }
}
.btn-submit{
  cursor: pointer;
}
</style>
